package com.indra.archetypeweb.dao.disc;

import java.util.List;

import javax.persistence.PersistenceException;

import com.indra.archetypeweb.dao.base.BaseDaoImpl;
import com.indra.archetypeweb.entity.book.Book;
import com.indra.archetypeweb.entity.disc.Disc;

public class DiscDaoImpl extends BaseDaoImpl<Disc> implements DiscDao {

	@Override
	public List<Disc> findAll() {
		
		return em.createNamedQuery(Disc.FIND_ALL, Disc.class).getResultList();
	}

	@Override
	public List<Disc> findByCategory(Long idCategory) {
		try {
			return em.createNamedQuery(Disc.FIND_BY_CATEGORY, Disc.class)
					.setParameter("idCategory", idCategory).getResultList();
		} catch (PersistenceException e) {
			return null;
		}
	}

}
